<?php
/*
 * 防止刷新
 * @author     Mark <zhaody901@126.com>
 * @copyright  Copyright (c) 2013 lemon team
 * @version    $Id: 6e178cff158bf03eb4342f7bb8612a2130f2fff1 $
 * @time       14-2-7 上午10:26
 */
defined('IN_IXDCW') or exit('Access Denied');
if($DT['defend_cc']) {
	if(!DT_WIN && file_exists('/proc/loadavg')) {
		if($fp = @fopen('/proc/loadavg', 'r')) {
			list($loadaverage) = explode(' ', fread($fp, 6));
			fclose($fp);
			if($loadaverage > $DT['defend_cc']) {
				if(defined('DT_TASK')) exit;
				header("HTTP/1.0 503 Service Unavailable");
				exit(include(DT_ROOT.'/api/503.php'));
			}
		}
	}
}
if($DT['defend_reload']) {
	$lastvisit = intval(Crypt::decode(Cookie::get('lastvisit')));
	Cookie::set('lastvisit', Crypt::encode("$DT_TIME"));
	if($DT_TIME - $lastvisit < $DT['defend_reload']) {
		if(defined('DT_TASK')) exit;
		Prompt::message(lang('include->defend_reload', array($DT['defend_reload'])).'<script>setTimeout("this.location.reload();", '.($DT['defend_reload']*3000).');</script>');
	}
}
if($DT['defend_proxy']) {
	if($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_VIA'] || $_SERVER['HTTP_PROXY_CONNECTION'] || $_SERVER['HTTP_USER_AGENT_VIA'] || $_SERVER['HTTP_CACHE_INFO'] || $_SERVER['HTTP_PROXY_CONNECTION']) {
		if(defined('DT_TASK')) exit;
		Prompt::message(lang('include->defend_proxy'));
	}
}
?>